/**
 * 
 */
package pits.form;

import java.util.ArrayList;
import java.util.List;

import javax.portlet.ActionRequest;

import org.apache.log4j.Logger;

/**
 * @author ltd
 *
 */
public class EditEmployeeInfoForm {

	private String txtName;
	private String txtBirthday;
	private String txtAddress;
	private String txtPhone;
	private String txtEmail;
	private Byte txtGender;
	
	private static Logger log = Logger.getLogger("EditEmployeeInfoForm");
	
	public EditEmployeeInfoForm() {
		
	}
	public EditEmployeeInfoForm(ActionRequest request) {
		if (request.getParameter("txtName") != null) {
			setName(request.getParameter("txtName").toString());
		}
		if (request.getParameter("txtBirthday") != null) {
			setBirthday(request.getParameter("txtBirthday").toString());
		}
		if (request.getParameter("txtAddress") != null) {
			setAddress(request.getParameter("txtAddress").toString());
		}
		if (request.getParameter("txtGender") != null) {
			setGender(request.getParameter("txtGender").toString());
		}
		if (request.getParameter("txtPhone") != null) {
			setPhone(request.getParameter("txtPhone").toString());
		}
		if (request.getParameter("txtEmail") != null) {
			setEmail(request.getParameter("txtEmail").toString());
		}			
	}
	public String getName() {
		return txtName;
	}
	public void setName(String txtName) {
		this.txtName = txtName;
	}
	public String getBirthday() {
		return txtBirthday;
	}
	public void setBirthday(String txtBirthday) {
		this.txtBirthday = txtBirthday;
	}
	public String getAddress() {
		return txtAddress;
	}
	public void setAddress(String txtAddress) {
		this.txtAddress = txtAddress;
	}
	public String getPhone() {
		return txtPhone;
	}
	public void setPhone(String txtPhone) {
		this.txtPhone = txtPhone;
	}
	public String getEmail() {
		return txtEmail;
	}
	public void setEmail(String txtEmail) {
		this.txtEmail = txtEmail;
	}
	public Byte getGender() {
		return txtGender;
	}
	public void setGender(String txtGender) {
		this.txtGender = Byte.valueOf(txtGender);
	}
	
	public List<String> validate(EditEmployeeInfoForm form) {
		
		log.info("validate.start");	
		List<String> errList = new ArrayList<String>();
		if (this.txtName.isEmpty()) {
			errList.add("Name must be filled! Edit failed!");
		}
		if (this.txtAddress.isEmpty()) {
			errList.add("Address must be filled! Edit failed!");
		}
		if (this.txtPhone.isEmpty()) {
			errList.add("Phone must be filled! Edit failed!");
		} else {
			
		}
		if (this.txtEmail.isEmpty()) {
			errList.add("Email must be filled! Edit failed!");
		} else {
			
		}
		
		log.info("validate.end");
		return errList;
	}
}
